$(function () {
    $("#jqGrid").jqGrid({
        url: baseURL + 'quotePrintFactoryPrice/quoteprintfactoryprice/list',
        datatype: "json",
        colModel: [			
			{ label: 'id', name: 'id', index: 'id', width: 50, key: true },
			{ label: '工厂印刷机配置关联id', name: 'printFactoryId', index: 'print_factory_id', width: 80 }, 			
			{ label: '颜色', name: 'colour', index: 'colour', width: 80 }, 			
			{ label: '开机费', name: 'beginPrice', index: 'begin_price', width: 80 }, 			
			{ label: '递增价格(以1000印数递增)', name: 'stepPrice', index: 'step_price', width: 80 }, 			
			{ label: '涨价开机费', name: 'riseBeginPrice', index: 'rise_begin_price', width: 80 }, 			
			{ label: '涨价增幅价格,每1000多少钱', name: 'riseStepPrice', index: 'rise_step_price', width: 80 }, 			
			{ label: '免开机单价', name: 'largePrice', index: 'large_price', width: 80 }, 			
			{ label: '涨价免开机单价', name: 'riseLarge', index: 'rise_large', width: 80 }, 			
			{ label: '版费', name: 'printPlatePrice', index: 'print_plate_price', width: 80 }, 			
			{ label: '利润系数', name: 'floatingCoefficient', index: 'floating_coefficient', width: 80 }, 			
			{ label: '是否特种纸', name: 'canUv', index: 'can_uv', width: 80 }, 			
			{ label: '排序', name: 'printSizeSort', index: 'print_size_sort', width: 80 }, 			
			{ label: '是否删除(1删除,0不删除)', name: 'delFlag', index: 'del_flag', width: 80 }, 			
			{ label: '是否在前端显示(运用)(1显示,0不显示)', name: 'display', index: 'display', width: 80 }, 			
			{ label: '打印幅面尺寸宽', name: 'areaWide', index: 'area_wide', width: 80 }, 			
			{ label: '打印幅面尺寸长', name: 'areaLength', index: 'area_length', width: 80 }, 			
			{ label: '打印纸张尺寸宽', name: 'paperWide', index: 'paper_wide', width: 80 }, 			
			{ label: '打印纸张尺寸长', name: 'paperLength', index: 'paper_length', width: 80 }, 			
			{ label: '创建时间', name: 'createDate', index: 'create_date', width: 80 }, 			
			{ label: '更新时间', name: 'updateDate', index: 'update_date', width: 80 }, 			
			{ label: '创建人员', name: 'createUser', index: 'create_user', width: 80 }, 			
			{ label: '更新人员', name: 'updateUser', index: 'update_user', width: 80 }
        ],
		viewrecords: true,
        height: 385,
        rowNum: 10,
		rowList : [10,30,50],
        rownumbers: true, 
        rownumWidth: 25, 
        autowidth:true,
        multiselect: true,
        pager: "#jqGridPager",
        jsonReader : {
            root: "page.list",
            page: "page.currPage",
            total: "page.totalPage",
            records: "page.totalCount"
        },
        prmNames : {
            page:"page", 
            rows:"limit", 
            order: "order"
        },
        gridComplete:function(){
        	//隐藏grid底部滚动条
        	$("#jqGrid").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "hidden" }); 
        }
    });
});

var vm = new Vue({
	el:'#rrapp',
	data:{
		showList: true,
		title: null,
		quotePrintFactoryPrice: {}
	},
	methods: {
		query: function () {
			vm.reload();
		},
		add: function(){
			vm.showList = false;
			vm.title = "新增";
			vm.quotePrintFactoryPrice = {};
		},
		update: function (event) {
			var id = getSelectedRow();
			if(id == null){
				return ;
			}
			vm.showList = false;
            vm.title = "修改";
            
            vm.getInfo(id)
		},
		saveOrUpdate: function (event) {
			var url = vm.quotePrintFactoryPrice.id == null ? "quotePrintFactoryPrice/quoteprintfactoryprice/save" : "quotePrintFactoryPrice/quoteprintfactoryprice/update";
			$.ajax({
				type: "POST",
			    url: baseURL + url,
                contentType: "application/json",
			    data: JSON.stringify(vm.quotePrintFactoryPrice),
			    success: function(r){
			    	if(r.code === 0){
						alert('操作成功', function(index){
							vm.reload();
						});
					}else{
						alert(r.msg);
					}
				}
			});
		},
		del: function (event) {
			var ids = getSelectedRows();
			if(ids == null){
				return ;
			}
			
			confirm('确定要删除选中的记录？', function(){
				$.ajax({
					type: "POST",
				    url: baseURL + "quotePrintFactoryPrice/quoteprintfactoryprice/delete",
                    contentType: "application/json",
				    data: JSON.stringify(ids),
				    success: function(r){
						if(r.code == 0){
							alert('操作成功', function(index){
								$("#jqGrid").trigger("reloadGrid");
							});
						}else{
							alert(r.msg);
						}
					}
				});
			});
		},
		getInfo: function(id){
			$.get(baseURL + "quotePrintFactoryPrice/quoteprintfactoryprice/info/"+id, function(r){
                vm.quotePrintFactoryPrice = r.quotePrintFactoryPrice;
            });
		},
		reload: function (event) {
			vm.showList = true;
			var page = $("#jqGrid").jqGrid('getGridParam','page');
			$("#jqGrid").jqGrid('setGridParam',{
                page:page
            }).trigger("reloadGrid");
		}
	}
});